package p.ithorns.tools.translator.annotation;


import p.ithorns.tools.translator.annotation.field.*;
import p.ithorns.tools.translator.annotation.meta.*;

import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * DictType
 *
 * @author Ht.L
 * @date 2024-06-03 22:29
 * @since 1.0.0
 */
public enum DictType {

    ENUM(EnumField.class, EnumDictMeta.class),

    MAP(MapField.class, MapDictMeta.class),

    SVC(SvcFiled.class, SvcDictMeta.class),

    BEAN(BeanField.class, BeanDictMeta.class),

    // MODEL(ModelField.class, ModelDictMeta.class),

    EXP(ExpField.class, ExpDictMeta.class),

    ;

    private final static Set<String> META_CLASS_NAMES = Arrays.stream(DictType.values())
            .map(DictType::getMetaClass)
            .map(Class::getName)
            .collect(Collectors.toSet());

    private final static Map<String, DictType> META_MAP = Arrays.stream(DictType.values())
            .collect(Collectors.toMap(DictType::getMetaClassName, v -> v, (v1, v2) -> v1));

    private final Class<?> originClass;

    private final Class<?> metaClass;

    DictType(Class<?> originClass, Class<?> metaClass) {
        this.originClass = originClass;
        this.metaClass = metaClass;
    }

    public static DictType metaTypeOf(String metaClassName) {
        return META_MAP.get(metaClassName);
    }

    public static Set<String> getMetaClassNames() {
        return META_CLASS_NAMES;
    }

    public Class<?> getOriginClass() {
        return originClass;
    }

    public Class<?> getMetaClass() {
        return metaClass;
    }

    public String getSimpleName() {
        return originClass.getSimpleName();
    }

    public String getFullName() {
        return originClass.getName();
    }

    public String getMetaClassName() {
        return metaClass.getName();
    }

}